﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data.OleDb;
using DAO;

/// <summary>
/// Summary description for ProductTypeDAO
/// </summary>
public class ProductTypeDAO
{
    public ProductTypeDAO()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    #region lay thong tin
    public static DataTable GetProductInformation()
    {
        string sQuery = "select * from   ProductType";
        SqlConnection con = DataProvider.TaoKetNoi();
        DataTable dt = DataProvider.LayDataTable(sQuery, con);
        DataProvider.DongKetNoi(con);
        return dt;
    }
    #endregion
    #region them thong tin
    public static void EditInfo(ProductTypeDTO lspDTO)
    {
        string sQuery = "update ProductType set Gentility='" + lspDTO.Gentility + "' where CodeType=" + lspDTO.CodeType;
        SqlConnection con = DataProvider.TaoKetNoi();
        DataProvider.ExecuteNonQuery(sQuery, con);
        DataProvider.DongKetNoi(con);
    }
    public static bool AddProductType(ProductTypeDTO lspDTO)
    {
        string sQuery = "insert into ProductType(CodeType,Gentility) values(" + lspDTO.CodeType + ",'" + lspDTO.Gentility + "')";
        SqlConnection con = DataProvider.TaoKetNoi();
        bool kq = DataProvider.ExecuteNonQuery(sQuery, con);
        DataProvider.DongKetNoi(con);
        return kq;
    }
    public static void deleteTypeSP(ProductTypeDTO lspDTO)
    {
        string sQuery = "delete from ProductType where CodeType = " + lspDTO.CodeType;
        SqlConnection con = DataProvider.TaoKetNoi();
        DataProvider.ExecuteNonQuery(sQuery, con);
        DataProvider.DongKetNoi(con);
    }
    #endregion
}